const CompressionWebpackPlugin = require('compression-webpack-plugin')
const isProd = process.env.NODE_ENV === 'production'

module.exports = {
  css: {
    loaderOptions: {
      css: {},
      postcss: {
        plugins: [
          require('postcss-px2rem')({
            remUnit: 37.5
          })
        ]
      }
    }
  },
  configureWebpack: config => {
    if (isProd) {
      // 配置webpack 压缩
      config.plugins.push(
        new CompressionWebpackPlugin({
          test: /\.js$|\.html$|\.css$/,
          // 超过4kb压缩
          threshold: 4096
        })
      )
    }
  }
  // devServer: {
    // proxy: {
      // '^/kpi': {
      //   target: 'http://192.168.101.4',
      //   // pathRewrite: {'^/api' : ''}
      //   ws: true,
      //   changeOrigin: true,
      // },
      // '^/fdcloud-boot': {
      //   target: 'http://47.114.102.94:9090',
      // }
    // }
  // }
}